| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkInputs::GamepadDeviceManager Class Referencefinal

Manages gamepad devices available in a System. More...

Inheritance diagram for nkInputs::GamepadDeviceManager:

## Public Member Functions
System * | getSystem () const
GamepadDevice * | createOrRetrieve (nkMemory::StringView name)
GamepadDevice * | record (nkMemory::StringView name, nkMemory::UniquePtr< GamepadDevice > device)
GamepadDevice * | get (nkMemory::StringView name) const
GamepadDevice * | getByIndex (unsigned int index) const
void | rename (nkMemory::StringView currentName, nkMemory::StringView newName)
void | erase (nkMemory::StringView name)
nkMemory::UniquePtr< GamepadDevice > | relinquish (nkMemory::StringView name)

## Detailed Description

Manages gamepad devices available in a System.

At all times, managers own any memory allocated inside, through the creation methods, or ownership given to them. External code should never delete memory returned by it, unless the ownership is passed back through the dedicated method.

## Member Function Documentation

## ◆ getSystem()

System* nkInputs::GamepadDeviceManager::getSystem | ( |  | ) | const

Returns
  The System in which the manager works.

## ◆ createOrRetrieve()

GamepadDevice* nkInputs::GamepadDeviceManager::createOrRetrieve | ( | nkMemory::StringView | name | ) |

Creates if unavailable, or retrieves if available, a gamepad device.

Parameters

  name | The name of the device to retrieve.

Returns
  The device requested, possibly freshly created. The manager owns the memory returned, external code should never delete it. See erase().

## ◆ record()

GamepadDevice* nkInputs::GamepadDeviceManager::record | ( | nkMemory::StringView | name,
|  | nkMemory::UniquePtr< GamepadDevice > | device
| ) |  |

Records an already existing resource, passing its ownership to the manager. This method can be used after manually creating a resource, as needed, as long as the resource provided is part of the same System.

Parameters

  name | The name to register the resource to.
  device | The device to register.

Returns
  The raw pointer over the registered device.

Remarks
  The device provided needs to be living inside the same System as the Manager does. Doing so will fail the recording, log a warning and erase the device right away, as the ownership is passed during calling.

## ◆ get()

GamepadDevice* nkInputs::GamepadDeviceManager::get | ( | nkMemory::StringView | name | ) | const

Retrieves a gamepad device.

Parameters

  name | The name of the device to retrieve.

Returns
  The device requested if available, nullptr else.

## ◆ getByIndex()

GamepadDevice* nkInputs::GamepadDeviceManager::getByIndex | ( | unsigned int | index | ) | const

Retrieves a device by index. Keep in mind that as devices are added / erased, the same index can return a different device. This function is useful when retrieving all existing devices in one go.

Parameters

  index | The index from which to retrieve a device.

Returns
  The device currently attached to the index if available, nullptr else.

## ◆ rename()

void nkInputs::GamepadDeviceManager::rename | ( | nkMemory::StringView | currentName,
|  | nkMemory::StringView | newName
| ) |  |

Renames a gamepad device.

Parameters

  currentName | The name of the device to rename.
  newName | The name to reassign to the device.

## ◆ erase()

void nkInputs::GamepadDeviceManager::erase | ( | nkMemory::StringView | name | ) |

Erases and frees a gamepad device.

Parameters

  name | The name of the device to erase.

## ◆ relinquish()

nkMemory::UniquePtr<GamepadDevice> nkInputs::GamepadDeviceManager::relinquish | ( | nkMemory::StringView | name | ) |

Relinquishes a device's ownership, leaving its lifetime management to the caller.

Parameters

  name | The name of the device to return back.

Returns
  The device requested.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsInputs/Devices/Gamepads/GamepadDeviceManager.h